<?php

namespace App\Admin\Renders;

use App\Models\DomainPool;
use Dcat\Admin\Support\LazyRenderable;
use Dcat\Admin\Widgets\Table;
use Throwable;

class PoolDomainUsed extends LazyRenderable
{
    /**
     * @throws Throwable
     */
    public function render(): string
    {
        $info = DomainPool::find($this->key);

        $data = [];
        foreach ($info->spiders as $spider) {
            $data[] = [
                $spider->spiderable->getType(),
                $spider->spiderable->getTitle(),
                $spider->created_at,
            ];
        }

        return new Table(['活动类型', '活动名称', '关联时间',], $data);
    }
}
